﻿using DAL;
using MODEL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;

namespace BLL
{
   public class TruckTeamBLL
    {
        //调用DAL层的车队信息
        TruckTeamDAL truckteam = new TruckTeamDAL();

        #region 根据车队编号和车辆名称查询车队信息
        /// <summary>
        /// 根据车队编号和车辆名称查询车队信息
        /// </summary>
        /// <returns></returns>
        public DataTable GetTruckList()
        {
            return truckteam.GetTruckList();
        }
        #endregion

        #region 查询车队信息
        /// <summary>
        /// 查询车队信息
        /// </summary>
        /// <param name="TeamID"></param>
        /// <param name="Leader"></param>
        /// <returns></returns>
        public DataTable GetTruckTeamList(int TeamID, string Leader, int IsDelete)
        {
            return truckteam.GetTruckTeamList(TeamID, Leader, IsDelete);
        }
        #endregion

        #region 修改车队信息
        /// <summary>
        /// 修改车队信息
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public int UpdateTruckTeam(TruckTeamMODEL s)
        {
            return truckteam.UpdateTruckTeam(s);
        }
        #endregion

        #region 根据ID获取编辑车队信息
        /// <summary>
        /// 根据ID获取编辑车队信息
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public TruckTeamMODEL GetUpdateTruckTeamDAL(int teamid)
        {
            return truckteam.GetUpdateTruckTeamDAL(teamid);
        }
        #endregion

        #region 删除信息，1删除成功，0删除失败，-1已删除
        /// <summary>
        /// 删除信息
        /// </summary>
        /// <param name="delete"></param>
        /// <returns></returns>
        public int DeleteTruckTeam(int id)
        {
            TruckTeamMODEL team = truckteam.GetDeleteList(id);
            if (team.IsDelete)
            {
                return -1;
            }
            int result = truckteam.DeleteTruckTeam(id);
            if (result > 0)
            {
                return 1;
            }
            else
            {
                return 0;
            }
            //return tr.DeleteTruckTeam(id);
        }
        #endregion

        #region 删除车队信息根据id
        /// <summary>
        /// 删除车队信息根据id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public TruckTeamMODEL GetDeleteList(int id)
        {
            return truckteam.GetDeleteList(id);
        }
        #endregion

        #region 添加车队信息
        /// <summary>
        /// 添加车队信息
        /// </summary>
        /// <param name="sql"></param>
        /// <returns></returns>
        public int UInsertTruckTeam(TruckTeamMODEL sql)
        {
            return truckteam.UInsertTruckTeam(sql);
        }
        #endregion
    }
}
